import React from 'react'
import * as api from '../../utils/Zxapi'
import axios from 'axios'



export default (WrappenComponent)=>{
    return class Form extends React.Component{
        constructor(){
            super()
            /* 调用高阶组件===从后端获取数据==然后赋值给使用高阶组件的 */
            this.state = {
                setName: '',
                /* 满减活动的初始数据===满==减 */
                activeDidMoney:'',
                activeCutMoney:'',
                activeId:'',
                shopId:''
              };
        }
        /* 提取所有input框的双向数据绑定的onchange方法 */
        onChangeAll=(stateName,stateValue)=>{
            console.log(stateValue);
            this.setState({
                [stateName]:stateValue
            })
        }
        /* 调用 ===双向数据绑定的onchange方法*/
        useChange=(name)=>{
           return (e)=>this.onChangeAll(name,e.target.value)
        }
        /* 提取的提交的方法 */
        handleSubmit=(e)=>{
           e.parentDefalut()
        //    axios({

        //    })
        }
          /*初始化state里面数据的=====方法*/
        initValue=(value1,value2,activeIdValue,shopIdValue)=>{
            this.setState({
                activeDidMoney:value1,
                activeCutMoney:value2,
                activeId:activeIdValue,
                shopId:shopIdValue
            })
        }
        render(){
            // console.log(this.props);
            let methodsAll={
                Change:this.useChange,
                handle:this.handleSubmit,
                initValueSet:this.initValue
            }
            // console.log(this.state.activeId);
            return(
                <div>
                   {/* 我是input框的高阶组件==抽取input框的onchange和提交函数逻辑 */}
                    <WrappenComponent {...methodsAll} {...this.props} {...this.state}></WrappenComponent>
                </div>
            )
        }
        
    }
}